APPLY_AFTER_SALE = {}

APPLY_AFTER_SALE.order_id = '';

//初始化   popup
APPLY_AFTER_SALE.__INIT__ = function(oid){
	//保存order_id
	APPLY_AFTER_SALE.order_id = oid;
	
	//开启售后模块
	var source = $('.popup-after_sale').length;
	if(source == 0){
		$.get("src/my_center/order/apply_after_sale.html", function (data) {
            $("body").append(data);
        	myApp_.popup('.popup-after_sale');
        });
	}else{
        myApp_.popup('.popup-after_sale');
	}
	
}

//提交售后申请
APPLY_AFTER_SALE.submit = function(){
	//取值
	var memo = $('textarea.after_sale_reason').val().trim();
	
	if(!memo){
		my_tips_('请输入您的售后原因');
		return false;
	}
	
	request_(
		url_('api/V4/after_sale_add')
		,{
			order_id: APPLY_AFTER_SALE.order_id
			,memo: memo
		}
		,function(d){
			if(d.code == 0){
				my_tips_('提交售后成功，售后人员将竭力为您处理');
				APPLY_AFTER_SALE.close();
			}else{
				my_tips_(d.msg);
			}
		}
	);
	
}

//关闭
APPLY_AFTER_SALE.close = function(){
	//关闭popup
	myApp_.closeModal('.popup-after_sale');
	
	//清除popup  延时为了使动画完成
	setTimeout(function(){
		$('.popup-after_sale').remove();
	},500);
}
